<?php

/**
 * news actions.
 *
 * @package    Nika
 * @subpackage news
 * @author     Alexey Shapran (alexey.shapran@gmail.com)
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class newsActions extends sfActions
{
	/**
	 * Executes index action
	 *
	 * @param sfRequest $request A request object
	 */
	public function executeIndex(sfWebRequest $request)
	{		
		$this->pager = new sfDoctrinePager('news',sfConfig::get('app_maxnewsperpage'));
		$this->pager->setQuery(News::getLastNews());
		$this->pager->setPage($request->getParameter('page','1'));
		$this->pager->init();
	}

	public function executeView(sfWebRequest $request)
	{
		$this->news = $this->getRoute()->getObject();
		$this->forward404Unless($this->news);
		$response = $this->getResponse();
		$response->addMeta('keywords', $this->news['keywords']);
		$response->addMeta('description', $this->news['description']);
		$response->setTitle(sfConfig::get('app_title')." | ".$this->news['title']);
	}
}

